using Microsoft.EntityFrameworkCore;
using ApiText.Api.Models;

namespace ApiText.Api.Db
{
    public class ApiTextDb : DbContext
    {
        /// <summary>
        /// 采用依赖注入的方式的时，必须提供其构造函数，并且调用其父类构造函数
        /// </summary>
        /// <param name="options"></param>
        /// <returns></returns>
        public ApiTextDb(DbContextOptions options) : base(options)
        {

        }

        public DbSet<Users> Users { get; set; }
        public DbSet<Roles> Roles { get; set; }
        public DbSet<UserRoles> UserRoles { get; set; }
        public DbSet<AuditInfo> AuditInfo { get; set; }
  


          //添加种子数据
        protected override void OnModelCreating(ModelBuilder modelBuilder)
        {  
             modelBuilder.Seed();
        }


        //连接数据库
        protected override void OnConfiguring(DbContextOptionsBuilder options)
        {
            options.UseSqlServer(@"server=.;database=dbCore;uid=sa;pwd=123");
        }
    }
}